"""P10 10. 补充视频"""

"""
暴力递归就是尝试
1、把问题转化为规模缩小了的同类问题的子问题
2、有明确的不需要继续进行递归的条件(base case)
3、有当得到了子问题的结果之后的决策过程
4、不记录每一个子问题的解
"""


def hanoi(i: int, start: str = "左", end: str = "右", other: str = "中"):
    """汉诺塔问题，将i个盘子从左移动到右"""
    if i == 1:
        print(f"将1号盘子从{start}移动到{end}")
    else:
        hanoi(i - 1, start, other, end)
        print(f"将{i}号盘子从{start}移动到{end}")
        hanoi(i - 1, other, end, start)


def print_substring(s: str, i: int = 0, result: str = ""):
    """打印字符串的全部子串"""
    if i == len(s):
        print(result)
        return
    print_substring(s, i + 1, result + s[i])
    print_substring(s, i + 1, result)


if __name__ == "__main__":
    # hanoi(3)
    print_substring("abc")
